/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controlador;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Jaime
 */

public class conexiondb {
    
    public static void main(String args[]){
        conexiondb b=new conexiondb();
        b.conectar();
    }
    
    
    public void conectar(){       
            
        try{
            try {
                Class.forName("com.mysql.jdbc.Driver");
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(conexiondb.class.getName()).log(Level.SEVERE, null, ex);
            }
            Connection conexion=DriverManager.getConnection("jdbc:mysql://192.168.56.3/prueba2","usuario1","usuario1");
            java.sql.Statement st=conexion.createStatement();
            java.sql.ResultSet rs=st.executeQuery("SELECT *FROM curso");
            
            while(rs.next()){
                System.out.println("curso="+rs.getObject("codigo")+" nombre="+rs.getObject("nombre"));
            }
            rs.close();
            
        } catch (SQLException ex) {
            Logger.getLogger(conexiondb.class.getName()).log(Level.SEVERE, null, ex);
        }
        
            
        
        
    }
    
}
